# -*- coding:utf-8 -*-
"""
Author：Administrator
Date:2023年02月23日
"""

import docx
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
from docx.shared import Pt

myDocument = docx.Document('打折商品.docx')
# 设置第1节页眉
myDocument.sections[1].header.is_linked_to_previous=False
myParagraph1=myDocument.sections[1].header.paragraphs[0]
myParagraph1.text='这是第1节的页眉'
myParagraph1.alignment=WD_PARAGRAPH_ALIGNMENT.CENTER
myParagraph1.runs[0].font.size=Pt(16)
# 设置第2节页眉
myDocument.sections[2].header.is_linked_to_previous=False
myParagraph1=myDocument.sections[2].header.paragraphs[0]
myParagraph1.text='这是第2节的页眉'
myParagraph1.alignment=WD_PARAGRAPH_ALIGNMENT.CENTER
myParagraph1.runs[0].font.size=Pt(16)

# 设置第3节页眉
myDocument.sections[3].header.is_linked_to_previous=False
myParagraph1=myDocument.sections[3].header.paragraphs[0]
myParagraph1.text='这是第3节的页眉'
myParagraph1.alignment=WD_PARAGRAPH_ALIGNMENT.CENTER
myParagraph1.runs[0].font.size=Pt(16)

myDocument.save("02散文名篇.docx")

